**Knight Foundation - Lewis/McDaniel, July 2021
**PS: Political Science

set scheme plottig
graph set window fontface "Garamond"

**code variables

gen LMtreatment = dov_lewis_condition
recode LMtreatment -1=. 4=0
label define treatment 0 "Control" 1 "Equality" 2 "Christian Nationalism" 3 "Social Dominance"
label values LMtreatment treatment

gen pid3 = qpid100
recode pid3 -1=. 6=. 1=2 2=0 3=1
label define pid3 0 "Democrat" 1 "Independent" 2 "Republican"
label values pid3 pid3

gen white = 0
replace white = 1 if raceeth == 1

gen black = 0
replace black = 1 if raceeth == 2

gen hisp = 0
replace hisp = 1 if raceeth == 4 

rename q270 attend
recode attend -1=. 6=0 5=1 4=2 3=3 2=4 1=5

gen attend2 = attend
recode attend2 5=4
la define attend3 0 "Never Attend" 4 "Attend Weekly or More"
la value attend2 attend3

gen nonrelig = 0
replace nonrelig = 1 if q260 == 13

gen christian = 0
replace christian = 1 if q260 == 1 
replace christian = 1 if q260 == 2

gen christianW = 0
replace christianW = 1 if christian == 1 & raceeth == 1

gen protW = 0
replace protW = 1 if q260 == 2 & raceeth == 1
replace protW = 1 if q260 == 11 & raceeth == 1

gen protB = 0
replace protB = 1 if q260 == 2 & raceeth == 2

gen relig_oth = 0
replace relig_oth = 1 if q260 == 3 
replace relig_oth = 1 if q260 == 4 
replace relig_oth = 1 if q260 == 5 
replace relig_oth = 1 if q260 == 6 
replace relig_oth = 1 if q260 == 7 
replace relig_oth = 1 if q260 == 8
replace relig_oth = 1 if q260 == 9
replace relig_oth = 1 if q260 == 10
replace relig_oth = 1 if q260 == 12

gen reltrad = .
replace reltrad = 0 if protW==1
replace reltrad = 1 if protB==1
replace reltrad = 2 if q260 == 1
replace reltrad = 3 if nonrelig == 1
replace reltrad = 4 if relig_oth == 1

la define reltrad 0 "White Prot." 1 "Black Prot." 2 "Catholic" 3 "Non-Religious" 4 "Relig. Other"
la value reltrad reltrad

gen catholic = 0
replace catholic = 1 if q260==1

gen RFfund = q1_lewis_1
recode RFfund -1=. 
*reverse code so RF support is higher
recode RFfund 1=5 2=4 3=3 4=2 5=1

gen RFharm = q1_lewis_2
recode RFharm -1=. 

gen RFthreat = q1_lewis_3
recode RFthreat -1=. 
*reverse code so RF support is higher
recode RFthreat 1=5 2=4 3=3 4=2 5=1

gen RFssm= q1_lewis_4
recode RFssm -1=. 
*reverse code so RF support is higher
recode RFssm 1=5 2=4 3=3 4=2 5=1

gen RFhealth = q1_lewis_5
recode RFhealth -1=. 

gen RFmuslim = q1_lewis_6
recode RFmuslim -1=. 
recode RFmuslim 1=5 2=4 3=3 4=2 5=1

gen RFnative = q1_lewis_7
recode RFnative -1=.

**check randomization
anova ppage LMtreatment
anova ppgender LMtreatment
anova raceeth LMtreatment
anova ppeducat LMtreatment
anova pid3 LMtreatment
anova protW LMtreatment
anova nonrelig LMtreatment

**create DVs

gen RFmin2 = RFmuslim + RFnative
gen RFmin2X = (RFmin2-2)/8

gen RFmaj2 = RFssm + RFhealth
gen RFmaj2X = (RFmaj2-2)/8

gen RFgen2 = RFfund + RFharm + RFthreat 
gen RFgen2X = (RFgen2-3)/12

** Models for Figure 1 of paper (just treatments)
reg RFgen2X i.LMtreat [aweight=main_weights], robust
margins, at(LMtreat=(0 (1) 3)) l(76) saving(RF_gen, replace)
marginsplot, title("") ///
xlabel(,nogrid) xtitle("Treatments") ytitle("Low    <<    Support Religious Freedom     >>    High")

reg RFmaj2X i.LMtreat [aweight=main_weights], robust
margins, at(LMtreat=(0 (1) 3)) l(76) saving(RF_maj, replace)
marginsplot, title("") ///
xlabel(,nogrid) xtitle("Treatments") ytitle("Low    <<    Support Religious Freedom     >>    High")

reg RFmin2X i.LMtreat [aweight=main_weights], robust
margins, at(LMtreat=(0 (1) 3)) l(76) saving(RF_min, replace)
marginsplot, title("") ///
xlabel(,nogrid) xtitle("Treatments") ytitle("Low    <<    Support Religious Freedom     >>    High")

*Fig 1 for paper
combomarginsplot12 RF_gen RF_maj RF_min, labels("General RF" "Majority RF" "Minoirty RF") ///
xlabel(,nogrid) title("") ///
plot1op(mcolor(black) msymbol(O) lcolor(black)) ///
plot2op(mcolor(black) msymbol(Oh) lcolor(black) lp(shortdash)) ///
plot3op(mcolor(black) msymbol(Sh) lcolor(black) lp(longdash)) ///
ci1opts(lcolor(black)) ///
ci2opts(lcolor(black)) ///
ci3opts(lcolor(black)) ///
xlabel(,nogrid) xlabel(0 "Control" 1 "Equality" 2 `" "Christian" "Nat." "' 3 `" "Social" "Dom." "') ///
ytitle("Low    <<    Religious Freedom Support  >>   High") xtitle("Treatment") title("")

** Models for Figure 2 of paper (partisanship)

reg RFmin2X i.LMtreat##i.pid3 [aweight=main_weights], robust
margins, at(LMtreat=(0 1 2 3) pid= (0 1 2)) l(76)
marginsplot, title(" ") saving(RFminPID, replace) ///
xlabel(,nogrid) xlabel(0 "Control" 1 "Equality" 2 `" "Christian" "Nat." "' 3 `" "Social" "Dom." "') xtitle("") ytitle("") title("Minority RF") ///
plot1op(mcolor(black) msymbol(O) lcolor(black)) ///
plot2op(mcolor(black) msymbol(T) lcolor(gs8) lp(shortdash)) ///
plot3op(mcolor(black) msymbol(Sh) lcolor(black)lp(dash)) ///
ci1opts(lcolor(black)) ///
ci2opts(lcolor(gs8)) ///
ci3opts(lcolor(black)) ///
legend(position(6))

reg RFmaj2X i.LMtreat##i.pid3 [aweight=main_weights], robust
margins, at(LMtreat=(0 1 2 3) pid= (0 1 2)) l(76)
marginsplot, title(" ") saving(RFmajPID, replace) ///
xlabel(,nogrid) xlabel(0 "Control" 1 "Equality" 2 `" "Christian" "Nat." "' 3 `" "Social" "Dom." "') xtitle("") ytitle("") title("Majority RF") ///
plot1op(mcolor(black) msymbol(O) lcolor(black)) ///
plot2op(mcolor(black) msymbol(T) lcolor(gs8) lp(shortdash)) ///
plot3op(mcolor(black) msymbol(Sh) lcolor(black)lp(dash)) ///
ci1opts(lcolor(black)) ///
ci2opts(lcolor(gs8)) ///
ci3opts(lcolor(black)) ///
legend(position(6))

reg RFgen2X i.LMtreat##i.pid3 [aweight=main_weights], robust
margins, at(LMtreat=(0 1 2 3) pid= (0 1 2)) l(76)
marginsplot, title(" ") saving(RFgenPID, replace) ///
xlabel(,nogrid) xlabel(0 "Control" 1 "Equality" 2 `" "Christian" "Nat." "' 3 `" "Social" "Dom." "') xtitle("") ytitle("") title("General RF") ///
plot1op(mcolor(black) msymbol(O) lcolor(black)) ///
plot2op(mcolor(black) msymbol(T) lcolor(gs8) lp(shortdash)) ///
plot3op(mcolor(black) msymbol(Sh) lcolor(black)lp(dash)) ///
ci1opts(lcolor(black)) ///
ci2opts(lcolor(gs8)) ///
ci3opts(lcolor(black)) ///
legend(position(6))

*Fig 2 for paper
graph combine RFgenPID.gph RFmajPID.gph RFminPID.gph, ycommon row(1)

**Models for Figure 3 of paper (religious tradition)

reg RFmin2X i.LMtreat##i.reltrad [aweight=main_weights], robust
margins, at(LMtreat=(0 1 2 3) reltrad= (0 3)) l(76)
marginsplot, title(" ") saving(RFminR, replace) ///
xlabel(,nogrid) xlabel(0 "Control" 1 "Equality" 2 `" "Christian" "Nat." "' 3 `" "Social" "Dom." "') xtitle("") ytitle("") title("Minority RF") ///
plot1op(mcolor(black) msymbol(O) lcolor(black)) ///
plot2op(mcolor(black) msymbol(Sh) lcolor(black)lp(dash)) ///
ci1opts(lcolor(black)) ///
ci2opts(lcolor(black)) ///
legend(position(6))

reg RFmaj2X i.LMtreat##i.reltrad [aweight=main_weights], robust
margins, at(LMtreat=(0 1 2 3) reltrad= (0 3)) l(76)
marginsplot, title(" ") saving(RFmajR, replace) ///
xlabel(,nogrid) xlabel(0 "Control" 1 "Equality" 2 `" "Christian" "Nat." "' 3 `" "Social" "Dom." "') xtitle("") ytitle("") title("Majority RF") ///
plot1op(mcolor(black) msymbol(O) lcolor(black)) ///
plot2op(mcolor(black) msymbol(Sh) lcolor(black)lp(dash)) ///
ci1opts(lcolor(black)) ///
ci2opts(lcolor(black)) ///
legend(position(6))

reg RFgen2X i.LMtreat##i.reltrad [aweight=main_weights], robust
margins, at(LMtreat=(0 1 2 3) reltrad= (0 3)) l(76)
marginsplot, title(" ") saving(RFgenR, replace) ///
xlabel(,nogrid) xlabel(0 "Control" 1 "Equality" 2 `" "Christian" "Nat." "' 3 `" "Social" "Dom." "') xtitle("") ytitle("") title("General RF") ///
plot1op(mcolor(black) msymbol(O) lcolor(black)) ///
plot2op(mcolor(black) msymbol(Sh) lcolor(black)lp(dash)) ///
ci1opts(lcolor(black)) ///
ci2opts(lcolor(black)) ///
legend(position(6))

*Figure 3 for paper
graph combine RFgenR.gph RFmajR.gph RFminR.gph, ycommon row(1)

**Models for Figure A1 of paper (attendance)

reg RFmin2X i.LMtreat##i.attend2 [aweight=main_weights], robust
margins, at(LMtreat=(0 1 2 3) attend2= (0 4)) l(76)
marginsplot, title(" ") saving(RFminA2, replace) ///
xlabel(,nogrid) xlabel(0 "Control" 1 "Equality" 2 `" "Christian" "Nat." "' 3 `" "Social" "Dom." "') xtitle("") ytitle("") title("Minority RF") ///
plot2op(mcolor(black) msymbol(O) lcolor(black)) ///
plot1op(mcolor(black) msymbol(Sh) lcolor(black)lp(dash)) ///
ci1opts(lcolor(black)) ///
ci2opts(lcolor(black)) ///
legend(position(6))

reg RFmaj2X i.LMtreat##i.attend2 [aweight=main_weights], robust
margins, at(LMtreat=(0 1 2 3) attend2= (0 4)) l(76)
marginsplot, title(" ") saving(RFmajA2, replace) ///
xlabel(,nogrid) xlabel(0 "Control" 1 "Equality" 2 `" "Christian" "Nat." "' 3 `" "Social" "Dom." "') xtitle("") ytitle("") title("Majority RF")  ///
plot2op(mcolor(black) msymbol(O) lcolor(black)) ///
plot1op(mcolor(black) msymbol(Sh) lcolor(black)lp(dash)) ///
ci1opts(lcolor(black)) ///
ci2opts(lcolor(black)) ///
legend(position(6))

reg RFgen2X i.LMtreat##i.attend2 [aweight=main_weights], robust
margins, at(LMtreat=(0 1 2 3) attend2= (0 4)) l(76)
marginsplot, title(" ") saving(RFgenA2, replace) ///
xlabel(,nogrid) xlabel(0 "Control" 1 "Equality" 2 `" "Christian" "Nat." "' 3 `" "Social" "Dom." "') xtitle("") ytitle("") title("General RF") ///
plot2op(mcolor(black) msymbol(O) lcolor(black)) ///
plot1op(mcolor(black) msymbol(Sh) lcolor(black)lp(dash)) ///
ci1opts(lcolor(black)) ///
ci2opts(lcolor(black)) ///
legend(position(6))

*Figure A1 for paper
graph combine RFgenA2.gph RFmajA2.gph RFminA2.gph, ycommon row(1)
